#ifndef _NAND_SPI_H
#define _NAND_SPI_H
#include "stdint.h"
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

/*spi mode enum*/
typedef enum
{
    NAND_SPI_MODE=0,
    NAND_QPI_READ_MODE,
    NAND_QPI_WRITE_MODE,
} nand_spi_type;

/*cs enum*/

#define    NAND_CS_LOW 		0
#define    NAND_CS_HIGH		1

/*init spi interface*/
void nand_spi_init(void);

/*chip select control*/
void nand_spi_cs(uint8_t vol);

/*switch to spi or qpi*/
void nand_spi_mode(nand_spi_type mode);

/*read and write 1 bype*/
uint8_t nand_spi_rw(uint8_t wdata);

/*write n bytes*/
uint8_t nand_spi_cmd_send(const uint8_t *pwd, uint16_t len);

/*read n bytes*/
uint8_t nand_spi_read(uint8_t *prd, uint16_t len);

/*write n bytes*/
uint8_t nand_spi_write(const uint8_t *pwd, uint16_t len);

/*read n bytes*/
uint8_t nand_qpi_read(uint8_t *prd, uint16_t len);

/*write n bytes*/
uint8_t nand_qpi_write(const uint8_t *pwd, uint16_t len);

#endif
